import {Component} from 'react'

//定义并暴露一个Weather组件
export default class Weather extends Component{
	state = {isHot:true}
	render(){
		return (
			<div>
				<h2>今天天气很{this.state.isHot ? '炎热' : '凉爽'}</h2>
				<button onClick={this.changeW}>切换天气</button>
			</div>
		)
	}
	changeW = ()=>{
		//获取原来状态值
		const {isHot} = this.state
		//更新state
		this.setState({isHot:!isHot})
	}
}